package com.zznj.xzjc.adapter.index;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vondear.rxtool.RxActivityTool;
import com.vondear.rxtool.view.RxToast;
import com.vondear.rxui.view.dialog.RxDialogDownload;
import com.zznj.xzjc.R;
import com.zznj.xzjc.activity.FileDisplayActivity;
import com.zznj.xzjc.activity.NetPicShowActivity;
import com.zznj.xzjc.bean.index.CuiBanData;
import com.zznj.xzjc.bean.index.FileData;
import com.zznj.xzjc.net.entity.LcjdBean;
import com.zznj.xzjc.net.rxjava.HttpMethods;
import com.zznj.xzjc.utils.FileUtils;
import com.zznj.xzjc.utils.StringUtils;
import com.zznj.xzjc.utils.TimeUtils;
import com.zznj.xzjc.utils.fileutils.OkManager;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/7
 */
public class CuiBanAdapter extends BaseQuickAdapter<CuiBanData, BaseViewHolder> {

    public CuiBanAdapter(int layoutResId, @Nullable List<CuiBanData> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CuiBanData item) {
        helper.setText(R.id.cbDwlabel,"催办单位：")
                .setText(R.id.cbDw, StringUtils.isEmpty(item.getCreateOrgName())?item.getOrgName():item.getCreateOrgName())
                .setText(R.id.cbTimeLabel,"催办时间：")
                .setText(R.id.cbTime, TimeUtils.getTime(item.getSendCorrectTime(), "yyyy-MM-dd"))
                .setText(R.id.xgsmLabel,"相关说明：")
                .setText(R.id.xgsm, item.getSendContent())
                .setText(R.id.fjListLabel,"附件：");
        RecyclerView recyclerView = helper.getView(R.id.fjList);
        if(item.getFiles() != null && item.getFiles().size() > 0){
            helper.getView(R.id.fjtv).setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);

            ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
            recyclerView.setLayoutManager(linearLayoutManager);
            FileDataAdapter fjAdapter = new FileDataAdapter(R.layout.gyss_item_filedata, item.getFiles(),1);
            recyclerView.setAdapter(new FileDataAdapter(R.layout.gyss_item_filedata, item.getFiles()));
        }else{
            helper.getView(R.id.fjtv).setVisibility(View.VISIBLE);
            helper.setText(R.id.fjtv,"无");
            recyclerView.setVisibility(View.GONE);
        }
    }
}
